package uc.org.jkas.model;
import org.jkas.core.Model;
import java.util.HashMap;
public class AdminsM extends Model
{ 
	public AdminsM()
	{
	 primaryKey("uid");
	}

    public HashMap<String,String> getByName(String name)
	{return getByName(name,false);
	}

	public HashMap<String,String> getByName(String name,boolean is_enabled)
	{   HashMap<Integer,Object> params=new HashMap<Integer,Object>();
	    params.put(1,name);
		if(is_enabled){this.where("status=1");}
		return this.where("username=?").prepareRows(params);
	}

	public boolean exists(String username)
	{return exists(username,0);
	}

	public boolean exists(String username,int uid)
	{boolean res=false;
	   HashMap<String,String> info=null;
			      this.where(strc("username='",username,"'"));
					info=this.getRows();
					if(info!=null && !info.isEmpty())
		             { if(uid>0 && uid==toInt(info.get("uid")))
						 {res=false;}
					     else
						 {
						   res=true;
						 }
		             }
	 return res;
	}
}